n = int(input())
yy = list(map(int, input().split()))
xx = list(map(int, input().split()))

# 标记
vist = [[0] * n for _ in range(n)]
# 路径
path = [0]

d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
vist[0][0] = 1
yy[0] -= 1
xx[0] -= 1

# 暴力遍历每个方向
def dfs(i, j):
    # 找到出口
    if i == n - 1 and j == n - 1:
        # 检查箭靶上的箭是否都被用完
        if sum(yy)==sum(xx)==0:
            # 将路径中的编号用空格连接成字符串输出
            print(" ".join(map(str, path)))
        return

    for k in range(4):
        dx = i + d[k][0]
        dy = j + d[k][1]
        if 0 <= dx < n and 0 <= dy < n and vist[dx][dy] == 0:
            # 下一步
            if yy[dy] > 0 and xx[dx] > 0:
                # 能到下一步
                vist[dx][dy] = 1
                # 计算新位置的编号
                position = dx * n + dy
                path.append(position)
                yy[dy] -= 1
                xx[dx] -= 1
                dfs(dx, dy)
                # 回溯
                vist[dx][dy] = 0
                path.pop()
                yy[dy] += 1
                xx[dx] += 1

dfs(0, 0)